/**
 * @file 接口方法
 */

import {fetch} from '@/utils/fetch.js';
import {URL} from '@/api/constant.js';
import utils from '@/utils/index.js';

export function userLogin(params) {
  return fetch.post(URL.loginUri, {
    params: {
      method: 'post',
      ...params,
      pass: utils.secretPassword(params.pass)
    }
  });
}

export function userRegister(params) {
  return fetch.post(URL.registerUri, {
    params: {
      method: 'post',
      ...params,
      pass: utils.secretPassword(params.pass),
      checkPass: ''
    }
  });
}

export function getUserInfo(params) {
  return fetch.post(URL.getInfoUri, {
    params: {
      method: 'post',
      ...params
    }
  });
}

export function clickBoard(params) {
  return fetch.post(URL.clickUri, {
    params: {
      method: 'post',
      ...params
    }
  });
}

export function uploadAvatar(params) {
  return fetch.post(URL.uploadUri, {
    params: {
      method: 'post',
      ...params
    }
  });
}

export function getAllGame(params) {
  return fetch.post(URL.roomUri, {
    params: {
      method: 'post',
      ...params
    }
  });
}

export function createRoom(params) {
  return fetch.post(URL.createUri, {
    params: {
      method: 'post',
      ...params
    }
  });
}

export function enterRoom(params) {
  return fetch.post(URL.enterUri, {
    params: {
      method: 'post',
      ...params
    }
  });
}
